<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\assets\PrintAsset;
PrintAsset::register($this);
/* @var $this yii\web\View */
/* @var $model common\models\business\BusinessContractAdjustment */

$this->title = $model->number;
$this->params['breadcrumbs'][] = ['label' => 'Business Contract Adjustments', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="business-contract-adjustment-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>

                        <?=Html::button('打印', ['class' => 'btn btn-info','data-toggle'=>"modal",'data-target'=>"#printmodel"]) ?>

                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'id',
                            'contractname',
                            'num',
                            'price',
                            [
                                'attribute' => 'createtime',
                                'format' => ['date', 'php:Y-m-d H:i:s'],
                            ]
                        ],
                    ]) ?>

                </div>
            </div>
        </div>
    </section>
</section>




<!--打印模态窗-->
<div class="modal fade  bs-example-modal-lg" id="printmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="overflow-y: scroll;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="kucuntitle">调整单</h4>
            </div>
            <div class="modal-body">
                <!--打印区域-->
                <div class="row" style="background: #fff"><!--打印结算明细区域-->
                    <div id="printarae" class="col-md-12">

                        <h4 style="margin-bottom: 10px;text-align: center">调整单</h4>

                        <?php if(!empty($model->sta)) { ?>
                        <div class="col-md-10 col-md-offset-1">
                            <span style="width:50%;display: block;float: left;">乙方:<?= $model->contract->partyB ?></span>
                            <span style="width: 50%;display: block;float: right;">结算时间：<?= date('Y-m-d',$model->createtime) ?></span>
                        </div>
                        <div class="col-md-10 col-md-offset-1">
                            <span style="width: 50%;display: block;float: left;">合同编号:<?= $model->contract->no ?></span>
                            <span style="width: 50%;display: block;float: left;">联系人:<?= $model->sta->connect_person ?></span>
                        </div>
                        <div class="col-md-10 col-md-offset-1">
                            <span style="width:50%;display: block;float: left;">联系地址:<?= $model->sta->connect_address?></span>
                            <span style="width: 50%;display: block;float: left;">联系电话:<?= $model->sta->connect_tel?></span>
                        </div>
                        <div class="col-md-10 col-md-offset-1">
                            <span style="width: 50%;display: block;float: left;">结算单编号:<?= $model->sta->number ?></span>
                            <span style="width: 50%;display: block;float: right;">付款情况：<?php if($model->sta->status == 1){ ?>未付款<?php }else {?>已付款<?php } ?></span>
                        </div>
                        <?php } ?>
                        <div class="col-md-10 col-md-offset-1">
                                <table class="table table-bordered">
                                    <tr>
                                        <th>单号</th>
                                        <th>调整数量</th>
                                        <th>调整价格</th>
                                        <th>调整原因</th>
                                    </tr>
                                    <tr>
                                        <td><?= $model->number ?></td>
                                        <td><?= $model->num ?></td>
                                        <td><?= $model->price ?></td>
                                        <td><?= $model->remark ?></td>
                                    </tr>
                                </table>
                        </div>
                        <div class="col-md-10 col-md-offset-1">
                            <div class="col-md-12">
                                <div style="width:50%;float: left;">总计：<?= $model->price  ?> 元</div>
                                <div style="width:50%;float: left;">数量：<?= $model->num ?></div>
                            </div>
                            <div class="col-md-12">
                                <div style="width:35%;float: left;">制单人:<?= $model->input_user ?></div>
                                <div style="width:30%;float: left;">审核人:<?= $model->agree_user?$model->agree_user:'未审核' ?></div>
                                <div style="width:35%;float: right;">审核日期:<?= $model->agree_time?date('Y-m-d',$model->agree_time):'' ?></div>
                            </div>
                        </div>
                        <div class="col-md-2 col-md-offset-10"><button class="btn btn-primary" id="print">打印</button></div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script>
        <?php $this->beginBlock('js_end') ?>

        //打印
        $(function(){
            $("#print").printPreview({
                obj2print:'#printarae',
                width:'810'
            });
        });
        <?php $this->endBlock(); ?>
        <?php $this->registerJs($this->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
    </script>
